<?php
$server="localhost";
$name="root";
$pwd="123456";
$db="aliya";

$con=mysqli_connect($server,$name,$pwd,$db);

$name=$_POST['name'];
$age=$_POST['age'];
$ads=$_POST['ads'];
$tel=$_POST['tel'];
$kaspi=$_POST['kaspi'];
$id=$_POST['id'];


if ($con) {
//    if ($id == 0) {
        $sql = "insert into aliya1(name,age,ads,tel,kaspi) values('$name','$age','$ads','$tel','$kaspi')";
    } else {
        $sql = "update aliya1 set name='$name',age='$age',ads='$ads',tel='$tel',kaspi='$kaspi' where id = $id";

    }
    $run = mysqli_query($con, $sql);
    if ($run) {
        echo "添加成功";
    } else {
        echo "添加失败" . mysqli_connect_error();
   }
}else{
    echo "数据库连接失败".mysqli_connect_error();
}



//    $sum= mysqli_query($con,$go);
//    if ($sum){
//        echo "添加成功";
//    }else{
//        echo "添加失败".mysqli_error($con);
//    }
//
//}else{
//echo "数据库连接失败".mysqli_connect_error();



